package com.siyu.basedata.pptnrfuture.controller;

import com.siyu.basedata.pptnrfuture.domain.PptnRFuture;
import com.siyu.basedata.pptnrfuture.service.IPptnRFutureService;
import com.siyu.common.core.controller.BaseController;
import com.siyu.common.core.domain.AjaxResult;
import com.siyu.common.core.page.TableDataInfo;
import com.siyu.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 雨量历史数据Controller
 *
 * @author hrhy
 * @date 2024-06-20
 */
@RestController
@RequestMapping("/basedata/pptnrfuture")
public class PptnRFutureController extends BaseController {
    @Autowired
    private IPptnRFutureService pptnRFutureService;

    /**
     * 查询雨量历史数据列表
     */
    @GetMapping("/list")
    public TableDataInfo list(PptnRFuture pptnRFuture) {
        startPage();
        List<PptnRFuture> list = pptnRFutureService.selectPptnRFutureList(pptnRFuture);
        return getDataTable(list);
    }

    /**
     * 导出雨量历史数据列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, PptnRFuture pptnRFuture) {
        List<PptnRFuture> list = pptnRFutureService.selectPptnRFutureList(pptnRFuture);
        ExcelUtil<PptnRFuture> util = new ExcelUtil<PptnRFuture>(PptnRFuture.class);
        util.exportExcel(response, list, "雨量历史数据数据");
    }

    /**
     * 获取雨量历史数据详细信息
     */
    @GetMapping(value = "/{stcd}")
    public AjaxResult getInfo(@PathVariable("stcd") String stcd) {
        return success(pptnRFutureService.selectPptnRFutureByStcd(stcd));
    }

    /**
     * 新增雨量历史数据
     */
    @PostMapping
    public AjaxResult add(@RequestBody PptnRFuture pptnRFuture) {
        return toAjax(pptnRFutureService.insertPptnRFuture(pptnRFuture));
    }

    /**
     * 修改雨量历史数据
     */
    @PutMapping
    public AjaxResult edit(@RequestBody PptnRFuture pptnRFuture) {
        return toAjax(pptnRFutureService.updatePptnRFuture(pptnRFuture));
    }

    /**
     * 删除雨量历史数据
     */
    @DeleteMapping("/{stcds}")
    public AjaxResult remove(@PathVariable String[] stcds) {
        return toAjax(pptnRFutureService.deletePptnRFutureByStcds(stcds));
    }
}
